The Gambit Scheme Interpreter is one component of the Gambit Scheme System.
Also available are, a version with a native code compiler and a linker that
can be used to build standalone applications (check the about... menu).
All of these applications run on Mac+/SE/II computers. For the interpreter
you need at least 850K of free RAM to run the program. This means that
it is possible to run it on a 1 meg Mac as long as you are not using some
other RAM consuming programs, such as special INIT's, ramdisks or the
Multifinder. Chances are you won't have enough free space on a 1 meg Mac
running system 7.0.
Gambit Interpreter
------------------
The Gambit Interpreter (GSI for short) is a Scheme interpreter that
can be used to develop and debug Gambit Scheme programs. GSI conforms
to the IEEE-Scheme standard as well as the R3.99RS report on Scheme. In
addition, GSI has the ability to dynamically load object files (i.e.
files with a .O extension) produced by the Gambit compiler. GSI's
debugging environment supports program interrupt, error resume and abort.
Gambit v1.8 implements the complete numeric tower defined in the standard,
that is, exact integers of arbitrary precision (bignums), rationals,
inexact reals (floating point) and complex numbers. GSI also has a few
extensions to the standard, for example, pretty printing routines and
multitasking support. Some of the Macintosh toolbox procedures
are also available from the interpreter.
When GSI is launched, it grabs most of the memory for its heap and leaves
the rest for the Mac's own needs. Note that under Multifinder it is
possible to limit the amount of memory used by GSI by changing GSI's
memory requirement information with the finder's <cmd>-I command.
Unfortunately, this means that on a small system (e.g. 1 meg Mac) there
is a good chance that the Mac will run out of memory if you open too many
windows or desk accessories... so be careful. If you get an "Out of memory"
dialog box, close some of your windows and DA's or delete some of the text
in your interaction window.
If present, the file "init.scm" is loaded when GSI is launched. It can
be used to customize GSI to your own needs. The file can be either
in the same folder as the document being opened or in the same folder as
the interpreter.
Interaction with the Read-Eval-Print loop
-----------------------------------------
Most of the interaction with GSI's read-eval-print (REP) loop is done
through the keyboard. To evaluate an expression, place the edit cursor
after the end of the expression and press <enter>. This will send the
expression to the interpreter for evaluation and the result will be
displayed in the interaction window. In addition, it is possible to
send arbitrary text to the interpreter by selecting it before pressing
<enter>. These evaluation mechanisms also work in windows attached to
files (however the result is always displayed in the interaction
window). For example, if you are reading this file from GSI, place the
edit cursor after the closing parenthesis of (* 3 5) and press <enter>.
The value 15 will be printed on the interaction window. The tab key can
be used to indent the code.
In general, Scheme expressions typed in a REP loop are evaluated and
the result printed out. When an evaluation error occurs, a REP loop of
a higher level is entered (the topmost REP loop is numbered 0). A <cmd>-D
will cause the current REP loop to be aborted and the previous REP loop will be resumed. As opposed to most other Lisp systems, GSI combines the standard REP
loop functions with those of the debugger. In a sense, you are always in
debugging mode. You can at all times examine the frames in the REP loop's
continuation (i.e. the call stack). This is useful to determine what part of
the program signaled an error. Also, an expression typed in to the REP loop
will be evaluated in the context of the frame currently being examined. Check
the examples for details. Special commands accepted in a REP loop are:
- <cmd>-R Return from an error or interrupt (you must also supply a value).
- <cmd>-D Returns to the previous REP loop (also acts as end-of-file).
- <cmd>-T Returns to the top-most REP loop.
- <cmd>-H Give summary of commands.
- <cmd>-+ Move to next frame of the continuation. (<cmd>-= works also)
- <cmd>-- Move to previous frame of the continuation.
- <cmd>-B Display a summary of each frame in the continuation
starting with the current frame. There are 3 columns.
The first is the frame number. The second is the procedure
that created the frame (and where control will return when
this frame is resumed). The last column, if it is present,
is the expression whose value is being computed. A frame
created by a compiled procedure has a third column only
if the procedure was compiled with the DEBUG option.
- <cmd>-L List all non-global variables accessible from the current frame.
- <cmd>-P Pretty print the procedure that created the current frame.
- <cmd>-E Display subproblem expression for the current frame.
- <cmd>-. This can be typed at any moment to interrupts the current
computation and starts a new REP loop.
- <cmd>-J Load a file.
Here is a transcript of a typical interaction with GSI (comments are